package net.csdn.business.auth.listener.handler;

import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Desc:
 * @ClassName: CustomAuthenticationSuccessEventHandler
 * @Author: yourleige@163.com
 * @Date: 2022/9/27 14:05
 */
@Slf4j
@Component
@AllArgsConstructor
public class CustomAuthenticationSuccessEventHandler implements AuthenticationSuccessHandler {

	/**
	 * 处理登录成功方法
	 * <p>
	 * 获取到登录的authentication 对象
	 * @param authentication 登录对象
	 * @param request 请求
	 * @param response 返回
	 */
	@Override
	public void handle(Authentication authentication, HttpServletRequest request, HttpServletResponse response) {
		String username = authentication.getName();
		log.info("用户：{} 登录成功", username);
	}

}
